import {createRouter, createWebHistory} from 'vue-router'
import HomeView from '../views/HomeView.vue'
import menus from './menu'

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        // 基础路由
        {
            path:"/",
            redirect:"/login"
        },
         {
            path: '/login',
            name: 'login',
            component: () => import('../views/Login.vue')
        },
        {
            path: '/register',
            name: 'register',
            component: () => import('../views/Register.vue')
        },
        {
            path: '/home',
            name: 'home',
            component: HomeView,
            children:menus
            
        },
        {
            path: '/forgetpassword',
            name: 'forgetpassword',
            component: () => import('../views/ForgotPassword.vue')
        },
        {
            path: '/my-bikes',
            name: 'OwnBicycles',
            component: () => import('../views/user/OwnBicycles.vue')
        },
  // 添加 obdetails 路由，使用动态参数 :id
        {
            path: '/obdetails/:id',
            name: 'OBDetail',
            component: () => import('../views/user/OBDetails.vue')
            
        },


       
    ]
})
router.beforeEach((to, from, next) => {
    console.log('路由前置导航守卫==', to, from)
    next()

})

export default router
